import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../model/login_config_model.dart';
import 'login_phone_page.dart';
import 'widget/agreement_widget.dart';

class LoginPage extends StatefulWidget {
  const LoginPage({super.key, required this.config});

  final LoginConfig config;

  @override
  State<LoginPage> createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  bool isChecked = false;

  String userID = '';
  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: Stack(
        children: [
          Image.asset('assets/app/images/auth/background_top_image.png'),
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(
                  margin: EdgeInsets.only(left: 59.w, top: 42.h),
                  child: Image.asset('assets/app/images/auth/auth_logo_text.png', width: 94.5.w)),
              const SizedBox(height: 40),
              Container(
                  margin: EdgeInsets.only(left: 115.h),
                  child: Stack(
                    children: [
                      Image.asset('assets/app/images/auth/auth_logo_pop.png', width: 195.w),
                      Container(
                          margin: EdgeInsets.only(top: 15.h, left: 20.w),
                          child: Text('快加入鱼塘吧~',
                              style: TextStyle(
                                  color: const Color(0xFF6D7998), fontSize: 17.sp, fontWeight: FontWeight.w600))),
                    ],
                  )),
              Image.asset('assets/app/images/auth/auth_logo_bg.png', width: double.infinity),
              GestureDetector(
                onTap: () {},
                child: Container(
                  margin: EdgeInsets.symmetric(horizontal: 32.w),
                  height: 44.h,
                  alignment: Alignment.center,
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(22.r)),
                      gradient: const LinearGradient(colors: [Color(0xFF08101D), Color(0xFF4A70A4)])),
                  child: Text(
                    "本机号码一键登录".tr,
                    style: TextStyle(color: Colors.white, fontSize: 16.sp, fontWeight: FontWeight.w500),
                  ),
                ),
              ),
              const SizedBox(height: 30),
              BrnNormalButton(
                text: "验证码登录".tr,
                textColor: const Color(0xFF25D4D0),
                backgroundColor: Colors.transparent,
                alignment: Alignment.center,
                onTap: () {
                  Get.offAll(LoginPhonePage(config: widget.config));
                },
              ),
              Padding(
                padding: const EdgeInsets.symmetric(horizontal: 32),
                child: AgreementWidget(
                    config: widget.config,
                    isChecked: isChecked,
                    onChecked: () {
                      isChecked = !isChecked;
                      setState(() {});
                    }),
              ),
            ],
          ),
        ],
      ),
    );
  }
}
